s=str(input())
l=list(s)
l.sort()
s1="".join(l)
if (s1==s) and ((l.count("c")==l.count("b")) or (l.count("c")==l.count("a"))) and (l.count("a")!=0) and (l.count("b")!=0):
print("YES")
else:
print("NO")
#include <iostream>
#include <algorithm>
#include <math.h>
#include "string.h"
#include <vector>
#include <stack>
#include <queue>
using namespace std;
struct Node
{
int val = 0;
Node *le = nullptr;
Node *ri = nullptr;
};
Node *head;
void setVal(Node **cur, int pos, int cle, int cri)
{
//cout << "cle=" << cle << ", cri=" << cri << ", cur=" << cur << "\n";
if ((*cur) == nullptr)
{
(*cur) = new Node;
}
if (cle == cri)
{
(*cur)->val = 1;
return;
}
int m = (cle+cri)/2;
if (pos <= m)
{
setVal(&((*cur)->le), pos, cle, m);
}
else
{
setVal(&((*cur)->ri), pos, m+1, cri);
}
((*cur)->val)++;
}
int getAns(Node *cur, int le, int ri, int cle, int cri)
{
if (cur == nullptr || le > ri)
{
return 0;
}
if (le == cle && ri == cri)
{
return cur->val;
}
int m = (cri+cle)/2;
return getAns(cur->le, le, min(ri, m), cle, m) +
getAns(cur->ri, max(le, m+1), ri, m+1, cri);
}
char op[3][4] = {"MOV", "ADD", "SUB"};
uint8_t r[4];
char cmd[100000];
void opReg(int rix, int st, int val)
{
rix--;
switch(st)
{
case 0:
r[rix] = val;
break;
case 1:
r[rix] += val;
break;
case 2:
r[rix] -= val;
break;
}
cout << "r" << rix + 1 << "=" << (int)r[rix] << "\n";
}
bool isRegOk(int ix, int le, int &rix)
{
if (cmd[ix] < '1' || cmd[ix] > '4')
{
return false;
}
if (ix + 1 < le && (cmd[ix+1] == ' ' || cmd[ix+1] == ','))
{
rix = cmd[ix] - '0';
return true;
}
if (ix + 1 >= le)
{
rix = cmd[ix] - '0';
return true;
}
return false;
}
bool isDigit(char ch)
{
return (ch >= '0' && ch <= '9');
}
bool isNum(int ix, int le, int &val)
{
cerr << "isNum for " << cmd + ix << "\n";
int res = 0;
if (!isDigit(cmd[ix]))
{
return false;
}
res = cmd[ix] - '0';
ix++;
while (ix < le && isDigit(cmd[ix]))
{
res *= 10;
res += cmd[ix] - '0';
ix++;
}
//cout << "res=" << "\n";
if ((ix < le && (cmd[ix] == ' ' || cmd[ix] == '\r')) || ix == le)
{
val = res;
cout << "val=" << val << "\n";
return true;
}
//cout << "bug\n";
return false;
}
char s[5001];
void solve()
{
int n;
cin >> s;
n = strlen(s);
int c[2] = {0,0};
int pos = 0;
int cc =0;
while (pos < n && s[pos] == 'a') {c[0]++; pos++;}
while (pos < n && s[pos] == 'b') {c[1]++; pos++;}
while (pos < n && s[pos] == 'c') {cc++; pos++;}
if (pos < n || c[0] == 0 || c[1] == 0 || (c[0] != cc && c[1] != cc))
{
cout << "NO\n";
}
else
{
cout << "YES\n";
}
return;
}
void precalc()
{
}
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int t = 1;
//cin >> t;
precalc();
for (int i = 0; i < t; ++i)
{
solve();
}
return 0;
}
1399A - Remove Smallest | 208A - Dubstep |
1581A - CQXYM Count Permutations | 337A - Puzzles |
495A - Digital Counter | 796A - Buying A House |
67A - Partial Teacher | 116A - Tram |
1472B - Fair Division | 1281C - Cut and Paste |
141A - Amusing Joke | 112A - Petya and Strings |
677A - Vanya and Fence | 1621A - Stable Arrangement of Rooks |
472A - Design Tutorial Learn from Math | 1368A - C+= |
450A - Jzzhu and Children | 546A - Soldier and Bananas |
32B - Borze | 1651B - Prove Him Wrong |
381A - Sereja and Dima | 41A - Translation |
1559A - Mocha and Math | 832A - Sasha and Sticks |
292B - Network Topology | 1339A - Filling Diamonds |
910A - The Way to Home | 617A - Elephant |
48A - Rock-paper-scissors | 294A - Shaass and Oskols |